<?php

/**
 * Mediad co,ltd
 *
 * @category   Mediad
 * @package    Mediad2_Service
 * @subpackage Admin
 * @copyright  Copyright (c) 2012 Mediad co,ltd. (http://www.Mediad.cn)
 * @license    New BSD License
 * @version    $Id: AbstractInterface.php 1 2012-10-31 17:55:00Z tany@Mediad.cn $
 */


/**
 * @category   Mediad
 * @package    Mediad2_Service
 */
interface Mediad2_Service_AbstractInterface
{	
	/**
	 * 返回记录总数
	 *
	 * @param string $condition
	 * @return Mediad2_Model_Result the data include int The number of rows
	 */
	public function getCount($condition = null);
	
	/**
	 * 根据主键id，返回记录的其他信息
	 *
	 * @param int $id
	 * @return Mediad2_Model_Result the data include row
	 */
	public function find($id);
	
	/**
	 * 根据条件，返回记录的其他信息
	 *
	 * @param string $where
	 * @param array $order
	 * @return Mediad2_Model_Result the data include row
	 */
	public function findBy($where, $order = null);

	/**
	 * 返回符合条件的记录
	 *
	 * @param integer $pageIndex
	 * @param integer $pageNum
	 * @param string $where
	 * @param string $order
	 * @param boolean $returnArray
	 * @return Mediad2_Model_Result the data include array row
	 */
	public function fetchAll($pageIndex = 1, $pageNum = 20, $where = null, $order = null, $returnArray = false);

	/**
	 * 保存记录信息
	 *
	 * @param Mediad2_Model_Abstract $model
	 * @return Mediad2_Model_Result the data include mixed The primary key of the row inserted
	 */
	public function insert($model);
	
	/**
	 * 更新记录信息
	 *
	 * @param Mediad2_Model_Abstract $model
	 * @return Mediad2_Model_Result the data include int The number of rows updated.
	 */
	public function update($model);

	/**
	 * 根据主键id，删除指定的记录
	 *
	 * @param int $id
	 * @return Mediad2_Model_Result the data include int The number of rows deleted.
	 */
	public function delete($id);
	
	/**
	 * 根据条件，删除指定的记录
	 *
	 * @param string $condition
	 * @return Mediad2_Model_Result the data include int The number of rows deleted.
	 */
	public function deleteBy($condition);
	
	/**
	 * 根据条件，返回记录的指定字段的信息
	 *
	 * @param string $condition
	 * @param string $fields
	 * @param array $order
	 * @return Mediad2_Model_Result the data include row
	 */
	public function getFieldsBy($condition, $fields = null, $order = null);

}